<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>第三天 数据驱动视图</title>
	<style type="text/css">
		ul{
			list-style: none;
		}
		ul li{
			margin: 20px;
			padding: 10px 5px;
			border-radius: 50%;
			text-align: center;
			width: 300px;
		}
		.active{
			background-color: #66FFFF;
		}
	</style>
</head>
<body>
	<script type="text/javascript" src="./node_modules/vue/dist/vue.js"></script>
	<div id="app">
		<audio :src="getCurrentStoreValue" autoplay controls /></audio>
		<ul>
			<li v-for="(item,index) in muisc" @click="clickHandler(index)" :class='{active:index == id}'>
				<h3>歌曲名称：{{item.name}}</h3>
			</li>
		</ul>
	</div>
	<script type="text/javascript">
		let muisc = [{id:1,name:'爆炸隆隆声音效',storeValue:'./static/11181.mp3'},
					 {id:2,name:'风暴雨水环境音',storeValue:'./static/11182.mp3'},
					 {id:3,name:'狂桑巴节拍循环',storeValue:'./static/11183.mp3'},
					 {id:4,name:'孩子们在教室里吵疯',storeValue:'./static/11184.mp3'}];
		new Vue({
			el:'#app',
			data(){
				return{
					muisc:muisc,
					id:0
				}
			},
			methods:{
				clickHandler(index){
					this.id = index
				}
			},
			computed:{
				//计算属性默认只有get
				getCurrentStoreValue:function(){
					return this.muisc[this.id].storeValue
				}
			}
		})
	</script>
</body>
</html>
